package elitech.vietnam.weatherfashion.dto;

import java.util.Date;
import com.google.gson.annotations.SerializedName;

import elitech.vietnam.weatherfashion.ultilities.Utilities;

public class PostDTO {

	private int id;
	@SerializedName("id_store")
	private int storeId;
	@SerializedName("date")
	private String dateString;
	private Date dateShow;
	private String title;
	private String price;
	private String link;
	private String image;
	private String content;
	@SerializedName("create_day")
	private String createDayString;
	private Date createDay;
	private int status;
	private int likes;
	private int comments;
	private int type;
	@SerializedName("islike")
	private int countLike;
	private boolean isLiked = false;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getStoreId() {
		return storeId;
	}

	public void setStoreId(int storeId) {
		this.storeId = storeId;
	}

	public Date getDateShow() {
		try {
			if (dateShow == null)
				dateShow = Utilities.parseDateFromStringFormat(dateString,
						"yyyy-MM-dd");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return dateShow;
	}

	public void setDateShow(Date date) {
		this.dateShow = date;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getCreateDay() {

		if (createDay == null)
			createDay = Utilities.parseDateFromStringFormat(createDayString,
					"yyyy-MM-dd hh:mm:ss");
		return createDay;
	}

	public void setCreateDay(Date createDay) {
		this.createDay = createDay;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getLikes() {
		return likes;
	}

	public void setLikes(int likes) {
		this.likes = likes;
	}

	public int getComments() {
		return comments;
	}

	public void setComments(int comments) {
		this.comments = comments;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public boolean isLiked() {
		return (countLike > 0);
	}

	public void setLiked(boolean isLiked) {
		this.isLiked = isLiked;
		countLike = (!isLiked) ? 0 : 1;
	}

}
